﻿using PagedList;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WordDocumentGenerator.Library;

namespace GPS.ENTITYS
{
    public class Export_QDCongNhanTotNghiep
    {
        [Display(Name = "DVGTVT_MA")]
        public string DVGTVT_MA { get; set; }
        public string DATETIME_NOW { get; set; }
        public List<QDCongNhanTotNghiep_Title> LIST_TITLE { get; set; }
        public List<QDCongNhanTotNghiep_Detail> LIST_DETAIL { get; set; }
    }

    public class QDCongNhanTotNghiep_Title
    {
        public string DTTN_KH_MA { get; set; }
        public string DTTN_DVGTVT_MA { get; set; }
        public string DTTN_KH_LOP_MA { get; set; }
        [DisplayFormat(DataFormatString = "{0:0}", ApplyFormatInEditMode = true)]
        public Int32? SOHOCVIEN { get; set; }
    }

    public class QDCongNhanTotNghiep_Detail
    {
        public string HOTEN { get; set; }
        public string HV_NGAYSINH { get; set; }
        public string HV_SOCMT { get; set; }
        public string HV_NOITT { get; set; }
        public string HV_HS_SOCCN { get; set; }
    }
    public class View_Export_QDCongNhanTotNghiep
    {
        public int? Page { get; set; }
        public string dDVGTVT_MA { get; set; }
  //      public IPagedList<Export_HopDongDaoTaoLX> SearchResults { get; set; }
    }

    public class EXPORTWORD_QDCongNhanTotNghiep
    {
        public static byte[] EXPORT_QDCongNhanTotNghiep(string templateFileName, object objSource, string docType)
        {
            DocumentGenerationInfo generationInfo = GetDocumentGenerationInfo(docType, "1.0", objSource, templateFileName, false);

            COMMON.ExportCore<Export_QDCongNhanTotNghiep> docGenerator = new COMMON.ExportCore<Export_QDCongNhanTotNghiep>(generationInfo);

            return docGenerator.GenerateDocument();
        }
        /// <summary>
        /// Gets the document generation info.
        /// </summary>
        /// <param name="docType">Type of the doc.</param>
        /// <param name="docVersion">The doc version.</param>
        /// <param name="dataContext">The data context.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="useDataBoundControls">if set to <c>true</c> [use data bound controls].</param>
        /// <returns></returns>
        private static DocumentGenerationInfo GetDocumentGenerationInfo(string docType, string docVersion, object dataContext, string fileName, bool useDataBoundControls)
        {
            DocumentGenerationInfo generationInfo = new DocumentGenerationInfo();
            generationInfo.Metadata = new DocumentMetadata
            {
                DocumentType = docType,
                DocumentVersion = docVersion
            };
            generationInfo.DataContext = dataContext;
            generationInfo.TemplateData = File.ReadAllBytes(fileName);
            generationInfo.IsDataBoundControls = useDataBoundControls;

            return generationInfo;
        }

    }
}
